package com.fr.spark;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.List;

import com.hankcs.hanlp.model.crf.CRFLexicalAnalyzer;
import com.hankcs.hanlp.seg.common.Term;

/**
 * @author 付荣
 * @version 创建时间：2019年6月21日 上午11:16:44
 */
public class CRF {
    private static final String path = "E:\\ticket\\lvmama_hotel11.txt";
    private static final String writePath = "E:\\ticket\\lvmama_hotel_crf.txt";
    public static void main(String[] args) throws IOException {
        FileReader fr = new FileReader(path);
        BufferedReader br = new BufferedReader(fr);
        String line = br.readLine();
        FileWriter fw = new FileWriter(writePath);
        CRFLexicalAnalyzer analyzer = new CRFLexicalAnalyzer();
        while(line != null){
            String s[] = line.split("\t");
            List<Term> crfResult = analyzer.seg(s[1]);
            fw.append(line).append("\t").append(crfResult.toString()).append("\n");
            line = br.readLine();
        }
        br.close();
        fr.close();
        fw.close();
    }

}
